﻿using System;
using System.Diagnostics;

namespace DynamicVm
{
    [DebuggerStepThrough]
    public static class Contract
    {
        public static void Require<T>(bool cond, params object[] args) where T : Exception
        {
            if (!cond)
            {
                throw (Exception) Activator.CreateInstance(typeof (T), args);
            }
        }

        public static void NotNull<T>(T obj, string paramName) where T : class
        {
            Require<ArgumentNullException>(obj != null, paramName);
        }
    }
}
